<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
<link rel="stylesheet" type="text/css" href="./css/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="./css/themes/icon.css">
<link rel="stylesheet" type="text/css" href="./css/themes/color.css">
<link rel="stylesheet" href="./css/iconfont.css">
<link rel="shortcut icon" href="./iconfont/favicon.ico" />
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="./js/cookie.js"></script>

<style type="text/css">
	.login_item{
	    margin:20px auto;

	}
	.login_item span{
	    display:inline-block;
	    width:100px;
	    text-align:right ;
	}
body{
	background: url('./images/timg.jpg') no-repeat;
	background-size：100% 100%;
}
</style>
</head>
<body>
	<br>
	<div easyui-dialog id="login">
	   	<form id="loginForm" action="stud_doLogIn.action" method="post">
	        <div class="login_item"><span>用户名：</span>
	        <input type="text" id="user" name="LoginName" class="easyui-validatebox" data-options="required:true,missingMessage:'请填写登录名'" /></div>
	        <div class="login_item"><span>密    码：</span>
	        <input type="password" id="pass" name="LoginPwd" class="easyui-validatebox" data-options="required:true,missingMessage:'请填写密码'" /></div>
	    </form>
	</div>
	<script type="text/javascript">

		//根据后台返回的json数据进行判断
		// function chuLi(jsonData) {
		//     $.procAjaxMsg(jsonData, function () {
		//         window.location.href = jsonData.BackUrl;
		//     }, function () {
		//         $.alertMsg(jsonData.Msg, "登录提示！");
		//     });
		// }

		//添加dialog窗口，在窗口加两个按钮
		$(function () {
			$('#login').dialog({
				title: "用户登录",
				width: 350,
				height: 200,
				modal: true,
				closable: false,
				collapsible : true,	// 是否折叠
			minimizable :  true,	// 窗口最大化
			maximizable : true,	// 窗口最小化
			resizable : false,	// 是否可调整窗口大小
				buttons: [{
					text: "登录",
					iconCls: 'icon-ok',
					handler: function () {
						if ($('#loginForm').form('validate')) {//验证表单的正确性
							$.ajax({
							url:`http://182.254.177.121:3000/register/login`,
							type:'post',
							data: {
								username:$('#user').val(),
								password:$('#pass').val(),
							}
						}).done(function(data){
								if(data.length>0){
									addcookie('username',data[0].username,7);
									location.href = './';
								}else{
									$.messager.alert('警告','用户密码不正确');
								}
							})
						}
					}
				}, {
					text: "注册",
					iconCls: 'icon-edit',
					handler: function () {
						location.href="./register.html"
					}
				}]
			})
		})
	</script>
</body>
</html>
